﻿using AspDotNet.Core6.Mvc.ViewComponents.Services;
using Microsoft.EntityFrameworkCore;

namespace AspDotNet.Core6.Mvc.ViewComponents.Models
{
    public class ShoppingDbContext : DbContext
    {
        public DbSet<Prodcut>? Prodcuts { get; set; }
        public ShoppingDbContext(DbContextOptions<ShoppingDbContext> options)
            : base(options)
        {

        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            for (int index = 0; index < 20; index++)
            {
                modelBuilder.Entity<Prodcut>().HasData(new Prodcut()
                {
                    Id = index + 1,
                    Name = "Product" + (index + 1),
                    Price = index + 1,
                    Quantity = ((index + 1) * 10).ToString()
                });
            }
        }
    }
}
